package com.platform.license.config;

import com.platform.license.client.LicenseVerify;
import com.platform.license.client.LicenseVerifyParam;
import org.springframework.context.ApplicationListener;
import org.springframework.context.annotation.Profile;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
 * Description: 启动时安装证书
 *
 * @author libinal Created on 2019/9/22
 */
@Component
@Order(99)
@Profile("prod")
public class LicenseCheckListener implements ApplicationListener<ContextRefreshedEvent> {

    private final LicenseVerifyParam licenseVerifyParam;

    public LicenseCheckListener(LicenseVerifyParam licenseVerifyParam) {
        this.licenseVerifyParam = licenseVerifyParam;
    }

    @Override
    public void onApplicationEvent(ContextRefreshedEvent event) {
        LicenseVerify licenseVerify = new LicenseVerify();
        licenseVerify.install(licenseVerifyParam);
    }
}
